/**
 * Copyright (C) 2006 OQube 
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 *  
 * author: Arnaud Bailly - abailly AT oqube DOT com
 * created: 13 juin 2006
 */
package speculoos.beans;

/**
 * A map entry definition.
 * <p>
 * Instances of this class represent map entries definitions. A map entry 
 * definition is used to associate naem, types and values to synthetic maps.
 * </p>
 * 
 * @author abailly
 */
public class MapEntry {

	private String name;

	private String value = "null";

	private String type = "String";

	/**
	 * Create a new entry with given name.
	 * 
	 * @param key
	 *            the name of entry. May not be null.
	 */
	public MapEntry(String key) {
		if (key == null)
			throw new IllegalArgumentException("Name of entry cannot be null");
		this.name = key;
	}

	/**
	 * @return Returns the name.
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name
	 *            The name to set.
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return Returns the type.
	 */
	public String getType() {
		return type;
	}

	/**
	 * @param type
	 *            The type to set.
	 */
	public void setType(String type) {
		this.type = type;
	}

	/**
	 * @return Returns the value.
	 */
	public String getValue() {
		return value;
	}

	/**
	 * @param value
	 *            The value to set.
	 */
	public void setValue(String value) {
		this.value = value;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return name + " = " + value + (type == null ? "String" : " (" + type + ")");
	}

	/**
	 * Returns the capitalized name of this field.
	 * Assumes name is not null.
	 * 
	 * @return name of this field with first letter as capital
	 *  letter.
	 *  
	 */
	public String getCapname() {
		String f = name.substring(0,1).toUpperCase();
		return f + name.substring(1);
	}
}
